import  random
a = 1
b = 10
num = random.randint(a,b)
print(num)
money = 1000
while money>0:
    guess = input('请输入一个数：')
    if guess.isdigit():
        guess = int(guess)
    else:
        print("非法输入！")
        continue
    if guess < a or guess > b:
        print('请重新输入！')
        continue
    if guess > num:
        print('抱歉，大了')
        money-=500
        print('剩余',money,'金币')
    elif guess < num:
        print('抱歉，小了')
        money-=500
        print('剩余',money,'金币')
    else:
        print('恭喜你猜中了本轮幸运数字：',num)
        money+=3000
        print('剩余',money,'金币')
        flag = True
        while True:
            c = input('是否继续请输入y，退出输入q：')
            if c =='y':
                flag = False
                num = random.randint(1, 10)
                print(num)
                break
            elif c=='q':
                flag = True
            else:
                print('输入有误，请重新输入！')
            if a==2:
                print('游戏结束！')
                break
    if money<500:
        print('您的余额不足，请充值！')
        break





